package com.zq.widget.inverted.game.role.impl.effect;

import android.animation.FloatEvaluator;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.animation.DecelerateInterpolator;

import com.zq.widget.inverted.R;
import com.zq.widget.inverted.game.role.anim.Anim;
import com.zq.widget.inverted.game.role.anim.AnimProxy;
import com.zq.widget.inverted.game.role.anim.OnAnimUpdateListener;
import com.zq.widget.inverted.game.role.impl.base.DrawableRole;

/**
 * Created by zhangqiang on 2018/3/29.
 */
public class Boom extends DrawableRole{

    public Boom(Context context) {
        super(context, R.drawable.wsparticle_07);
    }

    @Override
    protected Anim<?> onCreateAnim() {
        return AnimProxy.ofFloat(255,0)
                .setDuration(300)
                .setTypeEvaluator(new FloatEvaluator())
                .setInterpolator(new DecelerateInterpolator())
                .setOnAnimUpdateListener(new OnAnimUpdateListener<Number>() {
                    @Override
                    public void onAnimUpdate(Anim<Number> anim) {
                        Drawable drawable = getDrawable();
                        if(drawable == null){
                            return;
                        }
                        drawable.setAlpha(anim.getAnimateValue().intValue());
                    }
                });
    }


}
